package com.ytktt.study.week11.task11.controller;

import com.ytktt.study.week11.task11.entity.User;
import com.ytktt.study.week11.task11.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @GetMapping("/user/find")
    public User find(@RequestParam Integer id) {
        return userService.find(id);
        //return new User(1,"KK", 28);
    }

    @GetMapping("/user/list")
    public List<User> list() {
        return userService.list();
//        return Arrays.asList(new User(1,"KK", 28),
//                             new User(2,"CC", 18));
    }
}
